var t = require("../../../../@babel/runtime/helpers/typeof"), a = getApp();

Page({
    data: {
        language: "",
        sType: "",
        level: "",
        return_time: "",
        ratioDatas: [],
        activeName: "first",
        first_content: [],
        second_content: [],
        third_content: [],
        fourth_content: [],
        loading: !1,
        allLoaded: !1,
        goload: !0,
        isLoadMore: !0,
        page: 1,
        total_page: 0,
        currentTabIndex: "0"
    },
    onLoad: function(t) {
        this.checkrouter(), this.initInfo(), this.getData("");
    },
    checkrouter: function() {
        try {
            var a = function() {
                for (var t = wx.getStorageSync("yz_basic_info"), a = t.popularize_page.mini.vue_route, e = 0; e < a.length; e++) if ("level_return" == a[e]) return console.log(t.popularize_page.mini.mini_url + "跳转的路径"), 
                wx.showToast({
                    title: "未开启推广权限",
                    duration: 1e3,
                    icon: "none",
                    success: function() {
                        setTimeout(function() {
                            wx.redirectTo({
                                url: t.popularize_page.mini.mini_url
                            });
                        }, 1e3);
                    }
                }), {
                    v: void 0
                };
            }();
            if ("object" === t(a)) return a.v;
        } catch (t) {
            console.log(t);
        }
    },
    onReady: function() {
        var t = wx.getStorageSync("langIndex");
        this.setData({
            language: t.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        this.data.isLoadMore ? this.getMoreData(this.data.page, this.data.sType) : wx.showToast({
            title: "没有更多了",
            icon: "none"
        });
    },
    onReachBottom: function() {
        this.getData();
    },
    onShareAppMessage: function() {},
    initInfo: function() {
        var t = this, e = a.getNetAddresss("plugin.level-return.api.level-return.get-level-return-statistic");
        a._getNetWork({
            url: e,
            success: function(a) {
                var e = a.data;
                if (1 === e.result) {
                    t.setData({
                        level: e.data.level,
                        return_time: e.data.return_time
                    });
                    var n = [], o = {};
                    o.money = e.data.amountTotal, o.data = "总返还金额", o.name = "data", n.push(o);
                    var i = {};
                    i.money = e.data.notReturn, i.data = "未返还金额", i.name = "data", n.push(i);
                    var s = {};
                    s.money = e.data.return_amount, s.data = "已返还金额", s.name = "data", n.push(s);
                    var r = {};
                    r.money = e.data.invalid, r.data = "无效金额", r.name = "data", n.push(r), t.setData({
                        ratioDatas: n
                    });
                } else wx.showToast({
                    title: e.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getData: function(t) {
        var e = this, n = a.getNetAddresss("plugin.level-return.api.level-return.get-return-log");
        n += "&status=" + t + "&page=1", a._getNetWork({
            url: n,
            success: function(a) {
                var n = a.data;
                1 === n.result ? (e.setData({
                    total_page: n.data.last_page
                }), "" == t ? e.setData({
                    first_content: n.data.data
                }) : "0" == t ? e.setData({
                    second_content: n.data.data
                }) : "1" == t ? e.setData({
                    third_content: n.data.data
                }) : "-1" == t && e.setData({
                    fourth_content: n.data.data
                })) : wx.showToast({
                    title: n.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getMoreData: function(t, e) {
        var n = this;
        if (this.data.page != this.data.total_page) if (this.data.page >= this.data.total_page) this.setData({
            loading: !0,
            allLoaded: !0
        }); else {
            t += 1;
            var o = a.getNetAddresss("plugin.level-return.api.level-return.get-return-log");
            o += "&status=" + e + "&page=" + t, a._getNetWork({
                url: o,
                success: function(t) {
                    var a = t.data;
                    if (1 === a.result) switch (n.setData({
                        loading: !1,
                        allLoaded: !1
                    }), e) {
                      case "":
                        n.setData({
                            first_content: n.data.first_content.concat(a.data.data)
                        });
                        break;

                      case "0":
                        n.setData({
                            second_content: n.data.second_content.concat(a.data.data)
                        });
                        break;

                      case "1":
                        n.setData({
                            third_content: n.data.third_content.concat(a.data.data)
                        });
                        break;

                      case "-1":
                        n.setData({
                            fourth_content: n.data.fourth_content.concat(a.data.data)
                        });
                    } else {
                        var o = n.data.page - 1;
                        n.setData({
                            page: o,
                            loading: !0,
                            allLoaded: !0,
                            isLoadMore: !1
                        });
                    }
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    onChange: function(t) {
        0 == t.detail.index ? this.getData("") : 1 == t.detail.index ? this.getData("0") : 2 == t.detail.index ? this.getData("1") : 3 == t.detail.index && this.getData("-1");
    }
});